Component({
  data: {
    selected: 0,
    color: "rgb(195,194,203)",
    selectedColor: "rgb(0, 131, 255)",
    tabBarList: [{
        id: 1,
        pagePath: "/pages/card/main",
        iconPath: "/images/v1/share.png",
        activePath:"/images/v1/share-active.png",
        text: "分享名片"
      },
      {
        id: 2,
        pagePath: "/pages/complain/main",
        iconPath: "/images/v1/complain.png",
        activePath:"/images/v1/complain-active.png",
        text: "投诉建议"
      },
      {
        id: 3,
        pagePath: "/pages/card/main",
        iconPath: "/images/v1/service2.svg",
        activePath:"/images/v1/share-active.png",
        text: '智能助手'
      },
      {
        id: 4,
        pagePath: "/pages/policy/main?id="+wx.getStorageSync('myCompanyId'),
        iconPath: "/images/v1/policy.png",
        activePath:"/images/v1/policy-active.png",
        text: "政策宣传"
      },
      {
        id: 5,
        pagePath: "/pages/notice/main?id="+wx.getStorageSync('myCompanyId'),
        iconPath: "/images/v1/notice.png",
        activePath:"/images/v1/notice-active.png",
        text: "通知公告"
      },
    ]
  },
  attached() {},
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      this.setData({
        selected: data.index
      })
      if (data.index == 1) {
        wx.addPhoneContact({
          firstName: this.data.cardUserInfo.user.userName,
          mobilePhoneNumber: this.data.cardUserInfo.user.phoneNumber,
          organization: this.data.cardUserInfo.company.name,
          email: this.data.cardUserInfo.user.email,
          title: this.data.cardUserInfo.user.companyPosition,
          success: (res) => {
            // console.log('addPhoneContactSuccess：', res);
          },
          fail: (err) => {
            console.log('addPhoneContactErr：', err);
          }
        })
      } else if (data.index == 3) {

      } else if (data.index == 2 || data.index == 4 || data.index == 5) {
        this.setData({
          selected: data.index
        })
        wx.navigateTo({
          url
        })
      }
    }
  }
})